/*
 * Copyright (c) 2011-2012 www.iflytek.com. All Rights Reserved.
 *  This software for customer relationship management system, developed by Noo team.
 *  Software code and design for the team, copy rights reserved.
 */
var count = 0;
var count2 = 0;
var editor;
var issue_add_visitor = function () {
	return {
        add_more:function()
        {
            var createobj_input=$('<input name="attachment" type="file"/>');
            var createobj_br=$('</br>');
            var createobj_del=$('<input type="button" value="'+language.common.remove+'"/>');

            $('#file').append(createobj_br);
            $('#file').append(createobj_input);
            $('#file').append(createobj_del);
            createobj_del.click(function(){
                 var  visitor_att_count=0;
                $("#file").find(":file").each(function()
                {
                    visitor_att_count+=1;
                })
                    if(visitor_att_count<=1)
                {
                    createobj_input.attr("value","");
                    return ;
                }
                else{
                    createobj_input.remove();
                    createobj_br.remove();
                    createobj_del.remove();
                }
            })
            createobj_input.change(function(){
                if ($.browser.ie) {

                } else {
                    file_size = this.files[0].size;
                    console.log(file_size/1024/1024 + "MB");

                    var size = file_size / 1024;
                    if(size > 10240){
                    	$.alert(language.issue.attachment_limit_msg,language.note.alert_title);
                        this.value="";
                        var num01 = file_size/1024;
                        num02 = num01.toFixed(2) ;
                    }else{
                        var num01 = file_size/1024;
                        num02 = num01.toFixed(2) ;
                    }
                }
                return true;
            })

        },
		init        : function () {
			$("#input_file").change(function () {
				var file_size = 0;
				if ($.browser.ie) {

				} else {
					console.log(file_size / 1024 / 1024 + " MB");

					var size = file_size / 1024;
					if (size > 10240) {
						$.alert(language.issue.attachment_limit_msg,language.note.alert_title);
						this.value = "";
						var num01 = file_size / 1024;
						num02 = num01.toFixed(2);
					} else {
						var num01 = file_size / 1024;
						num02 = num01.toFixed(2);
						if (size >= 10240) {
							$.alert(language.issue.attachment_limit_msg,language.note.alert_title);
						}
					}
				}
			})
		}
    }

}();

var visitor = function () {
	return {
		activation_notify: function () {
			$('#reporter_notify').attr('disabled', $('#tx_mail').val() == '');
		}
	};
}();